home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PWABFV20.ZIP / NFLAG.PPS < prev    next >
Text File  |  1995-02-19  |  16KB  |  493 lines

  1. ;
  2. ; Patched for use with Blackcat Viewer 2.0. 
  3. ; Patched for use with Blackcat Nuker 0.80 and up.
  4. ;
  5. ;
  6. ;******************************************************************************
  7. ;  FLAG.PPE version 3.0 released on 12/18/93 by David W. Terry
  8. ;
  9. ; FLAG.PPE is a replacement for PCBoard's internal "more?" prompt, gives
  10. ; PCBoard v15.1 the easiest-to-use system for flagging and viewing files of
  11. ; any BBS around.  It gives callers the ability to point and shoot when
  12. ; flagging or viewing files.
  13. ;
  14. ; NOTE:  Please DO NOT DISTRIBUTE modified source code without prior permission
  15. ; or without meeting the requirements set forth in FLAG.DOC.
  16. ;******************************************************************************
  17.  
  18. ' check to see if caller has ANSI capabilities and, if not, display the old
  19. ' prompt and exit - let PCBoard handle the input.
  20.  
  21. ;***********************************************************************
  22.  
  23.  
  24. ;*** BlackCAT NUKER ADDITION START 
  25. string nukecfg, nukefile, dirnr
  26. nukecfg = ppepath() + "flagnuke.cfg"
  27. if (!exist(nukecfg)) then
  28.     freshline
  29.     println "Error: Flag.ppe is setup to use NUKE.PPE but cannot"
  30.     println "find FLAGNUKE.CFG, please contact sysop"
  31.     end
  32. endif
  33. nukefile = readline(nukecfg, 1) + "\work\bcnk" + string(curconf()) +"."+ string(pcbnode())
  34. ;*** BlackCAT NUKER ADDITION END 
  35.  
  36. IF (! ANSION()) THEN
  37.   DISPFILE PPEPATH()+"FLAGOLD",LANG
  38.   END
  39. ENDIF
  40.  
  41. BOOLEAN exitflag       ' Flag to determine when we should exit
  42. BOOLEAN rip            ' Flag to indicate RIPscrip is in use
  43.  
  44. STRING  text           ' The text that the caller types
  45. STRING  key            ' Keystroke text
  46.  
  47. STRING  BS             ' An ASCII backspace character
  48. STRING  BS2            ' An ASCII backspace character
  49. STRING  CR             ' An ASCII carriage return character
  50. STRING  ESC            ' An ASCII esc character
  51.  
  52. BYTE    len            ' Length of the text the caller has typed
  53. BYTE    oldy           ' Last row position of cursor
  54. BYTE    newy           ' New row position of cursor
  55.  
  56. STRING  filenames(23)  ' The names of the files found on the screen
  57. STRING  filename       ' The name of the file that is being processed
  58. STRING  fileimage      ' Includes the color codes for restoration of text
  59.  
  60. ;***********************************************************************
  61.  
  62. ; Initializations
  63.  
  64. BS     = CHR(8)   ' Backspace Key
  65. BS2    = CHR(127) ' Alternate Backspace Key
  66. CR     = CHR(13)  ' Carriage Return
  67. ESC    = CHR(27)  ' ESC character
  68. len    = 0        ' Initialize to 0 bytes in the input buffer
  69. text   = ""       ' Initialize to an empty input buffer
  70.  
  71. ;***********************************************************************
  72.  
  73. ; Main Program
  74.  
  75.                              ' in case the last invocation of flag.ppe saved
  76. RESTSCRN                     ' the screen, restore it now
  77.  
  78. CLREOL                       ' clear the line for input
  79. GOSUB displayprompt          ' display the new prompt
  80. GOSUB scanforfiles           ' build filenames array
  81.  
  82. ' While the user hasn't exited, get keystrokes and act on them.
  83. ' Exiting will occur when the caller presses ENTER.
  84.  
  85. WHILE (!exitflag) DO
  86.  
  87.   key = INKEY()  ' Get a keypress from the user
  88.  
  89.   if (key <> "") THEN  ' If the user pressed a key, then let's process it
  90.  
  91.     ' If it is the FIRST keystroke, signified by the buffer having 0 bytes
  92.     ' in it, then check to see if it is a SPACE.  If so, then we'll go into
  93.     ' MARK mode.  If not, then we'll process the keystrokes the same way that
  94.     ' PCBoard would .. gathering them up into a buffer.  Once the ENTER key
  95.     ' is pressed, we'll exit out and stuff PCBoard's keyboard buffer with the
  96.     ' keystrokes that were collected.
  97.  
  98.     IF (len = 0 & key = " ") THEN
  99.       oldy = GETY()
  100.       newy = 0
  101.  
  102.       PRINT CR
  103.       CLREOL
  104.       PRINT ESC+"[s"  ' save the current cursor position
  105.  
  106.       ' Let the caller know what he can do while in MARK mode
  107.       DISPFILE PPEPATH()+"FLAGBAR",GRAPH+LANG
  108.  
  109.       ' Move the cursor back to the first column
  110.       PRINT CR
  111.  
  112.       ' Find the first filename on the screen.
  113.       GOSUB findfile
  114.  
  115.       ' If a filename was found, then findfile highlighted it.  Now wait for
  116.       ' another keystroke to see if the user whats to mark this one, or move
  117.       ' on to another one, or exit out.  Marking is done by pressing ENTER,
  118.       ' moving to another file is done by pressing SPACE, viewing the file is
  119.       ' done by pressing "V", and exiting is done by pressing ESC.
  120.  
  121.       IF (filename <> "") THEN
  122.  
  123.         ;*** BlackCAT NUKER PATCH START 
  124.         WHILE (key != ESC & key != CR & UPPER(key) != "V" & upper(key) != "N") DO
  125.         ;*** BlackCAT NUKER PATCH END 
  126.           key = INKEY()
  127.  
  128.           ' If the key pressed was a SPACE then the user has decided to skip
  129.           ' over that file.  So unhighlight it, then try to find another
  130.           ' file.  If a file is found, we'll stay in this loop.  If one is
  131.           ' not found, then we'll restore the original prompt and go back to
  132.           ' waiting for keystrokes in case the caller wants to start over
  133.           ' (marking files) or wants to manually (F)lag them instead.
  134.  
  135.           IF (key = " ") THEN
  136.             GOSUB unhighlight
  137.             GOSUB findfile
  138.             IF (filename = "") THEN
  139.               GOSUB restorecursor
  140.               GOSUB displayprompt
  141.               GOTO  bottom
  142.             ENDIF
  143.           ENDIF
  144.         ENDWHILE
  145.  
  146.         ' If we've gotten this far, then ESC, CR or V was pressed.  We'll
  147.         ' unhighlight the file, restore the prompt and then, if CR was pressed,
  148.         ' meaning the user wished to MARK that file, then will stuff PCBoard's
  149.         ' keyboard buffer with a FLAG command and the name of the file to flag.
  150.         ' If V was pressed, then we'll instead stuff the buffer with a command
  151.         ' to VIEW the file.
  152.  
  153.         GOSUB unhighlight
  154.         GOSUB restorecursor
  155.  
  156.         IF (key = CR) THEN
  157.           KBDSTUFF "F "+filename+CR
  158.           END
  159.         ELSEIF (UPPER(key) = "V") THEN
  160.           ' save the screen into PCBoard's memory so that we can restore it
  161.           ' when FLAG.PPE is called up again, then issue the view command
  162.           SAVESCRN
  163.       ; blackcat viewer
  164.           ;KBDSTUFF "V "+filename+CR
  165.           KBDSTUFF "F "+ CR + "/VIEW" + CR + filename + CR
  166.       ;blackcat viewer
  167.           END
  168.  
  169.         ;*** MAFIA NUKER ADDITION START 
  170.         ELSEIF (UPPER(key) = "N") THEN
  171.       savescrn
  172.       fclose -1
  173.       if (upper(readline(nukefile, 1)) <> u_name()) then
  174.            delete nukefile
  175.            fappend 1, nukefile, O_WR, S_DN
  176.            fputln 1, u_name() 
  177.       else
  178.            fappend 1, nukefile, O_WR, S_DN
  179.       endif
  180.       dirnr = string(pcbmac("@DIRNUM@"))
  181.           ; oops, assume upload dir, there's nothing we can do
  182.       if (dirnr == "") then 
  183.           dirnr = string(pcbmac("@NUMDIR@"))
  184.       endif
  185.       if (filename <> "") fputln 1, filename + " " + dirnr
  186.       fclose 1
  187.       println "@X0CFile targetted for nuking...."
  188.       delay 20
  189.       restscrn
  190.         ;*** MAFIA NUKER ADDITION END 
  191.         ENDIF
  192.       ELSE
  193.         GOSUB restorecursor
  194.       ENDIF
  195.  
  196.       GOSUB displayprompt
  197.       CONTINUE
  198.  
  199.     ELSEIF (key == BS | key == BS2) THEN
  200.  
  201.       ' If the caller pressed backspace or delete, then delete the character
  202.       ' to the left, and remove it from the input buffer.  Of course, if the
  203.       ' caller hasn't typed anything yet, or if the caller has already
  204.       ' backspaced everything out, signified by the len being 0 (meaning there
  205.       ' are 0 bytes in the buffer), then we'll just loop back around waiting
  206.       ' for more keystrokes
  207.  
  208.       IF (len > 0) THEN
  209.         PRINT BS+" "
  210.         len  = len - 1
  211.         text = LEFT(text,len)
  212.       ELSE
  213.         CONTINUE
  214.       ENDIF
  215.  
  216.     ELSEIF (key == CR) THEN
  217.  
  218.       ' If it's a carriage return then set the flag to exit
  219.       exitflag = TRUE
  220.  
  221.     ELSEIF (LEN(key) > 1 | key < " ") THEN
  222.  
  223.       ' Special keys, such as UP, DOWN, etc, return multi-letter values such
  224.       ' as "UP" and "DOWN" when the INKEY() function is called.  Since we just
  225.       ' want to ignore special characters, we'll use the CONTINUE statement to
  226.       ' jump back to the top of the loop
  227.       '
  228.       ' We also want to avoid displaying "control characters" so anything
  229.       ' less than a SPACE should also be skipped.
  230.  
  231.       CONTINUE
  232.  
  233.     ELSEIF ((len = 0) & ((key = "?") | (UPPER(key) = "H"))) THEN
  234.  
  235.       ' If the user typed "?" or "H" then we want to display a help file.
  236.       ' First we'll save the current screen, then display the help file, and
  237.       ' then restore the saved screen after the caller has read the help file.
  238.  
  239.       SAVESCRN
  240.       NEWLINE
  241.       DISPFILE PPEPATH()+"FLAGHLP",GRAPH+LANG
  242.       NEWLINE
  243.       WAIT
  244.       RESTSCRN
  245.       CONTINUE
  246.  
  247.     ELSEIF ((key >= " ") & (len < 80)) THEN
  248.  
  249.       ' Here we are just gathering up keystrokes and putting them into an
  250.       ' input buffer.  As long as the keystrokes are greater than or equal to
  251.       ' a SPACE we'll just add them in until a limit of 80 characters is
  252.       ' reached.  PCBoard won't let you type more than 80 characters at that
  253.       ' prompt anyway so we might as well keep the same limit.
  254.  
  255.       text = text + key
  256.       len  = len + 1
  257.  
  258.     ENDIF
  259.  
  260.     PRINT key    ' Print any keystrokes the caller types
  261.   ENDIF
  262.  
  263. :bottom
  264. ENDWHILE
  265.  
  266. ' If we've gotten this far, then the caller has pressed ENTER so we'll stuff
  267. ' whatever the caller has typed into PCBoard's input buffer and let PCBoard
  268. ' process the request.
  269. '
  270. ' But first, if the command begins with V then it may be a view files command.
  271. ' Verify that assumption by checking to see if the user typed "V" and pressed
  272. ' ENTER (check length equal to 1) or if the user typed "V filename" (check
  273. ' for length greater than or equal to 3 for "F f")
  274.  
  275. text = RTRIM(text," ")
  276.  
  277. IF (UPPER(LEFT(text,1)) = "V") THEN
  278.   IF (LEN(text) = 1) THEN
  279.     CLREOL
  280.     filename = ""
  281.     ; blackcat viewer start
  282.     ;PROMPTSTR 240,filename,12,MASK_FILE(),FIELDLEN
  283.     inputstr "@X07Filename to view (enter=none)", filename, 7, 12, mask_file(), fieldlen
  284.     ;blackcat viewer end
  285.     filename = RTRIM(filename," ");
  286.     IF (LEN(filename) = 0) THEN
  287.       CLREOL
  288.       KBDSTUFF CR
  289.       END
  290.     ENDIF
  291.     NEWLINE
  292.  
  293.     ' the lines below could be used to specify a different "default extension"
  294.     ' for archive files in different conferences - uncomment and adapt as
  295.     ' necessary to suit your needs
  296.     '
  297.     ' IF (INSTR(filename,".") = 0) THEN
  298.     '   IF (CURCONF() = 30) THEN
  299.     '     filename = filename + ".ARJ"
  300.     '   ELSEIF (CURCONF() = 50) THEN
  301.     '     filename = filename + ".ZOO"
  302.     '   ENDIF
  303.     ' ENDIF
  304.  
  305.     ; blackcat viewer start
  306.     ;text = "V "+filename
  307.     text = "V "+ CR + filename
  308.     ; blackcat viewer end
  309.     ' save the screen to PCBoard's memory so that the next invocation of
  310.     ' FLAG.PPE will restore the screen
  311.     SAVESCRN
  312.   ELSEIF (LEN(text) >= 3) THEN
  313.     ' save the screen to PCBoard's memory so that the next invocation of
  314.     ' FLAG.PPE will restore the screen
  315.     CLREOL
  316.  
  317.     ' the lines below could be used to specify a different "default extension"
  318.     ' for archive files in different conferences - uncomment and adapt as
  319.     ' necessary to suit your needs
  320.     '
  321.     ' IF (INSTR(filename,".") = 0) THEN
  322.     '   IF (CURCONF() = 30) THEN
  323.     '     text = text + ".ARJ"
  324.     '   ELSEIF (CURCONF() = 50) THEN
  325.     '     text = text + ".ZOO"
  326.     '   ENDIF
  327.     ' ENDIF
  328.  
  329.     SAVESCRN
  330.     ; blackcat viewer start
  331.     text = "F " + CR + "/VIEW" + CR + mid(text, 2, len(text) - 1)
  332.     ; blackcat viewer end
  333.   ELSE
  334.     KBDSTUFF CR
  335.     END
  336.   ENDIF
  337. ENDIF
  338.  
  339. KBDSTUFF text+CR
  340. END
  341.  
  342.  
  343. ;***********************************************************************
  344. '
  345. ' This subroutine restores the cursor position.  It does this using an ANSI
  346. ' command that simply restores a previously saved cursor position.  In
  347. ' addition, we'll clear the line before returning.
  348.  
  349. :restorecursor
  350. PRINT ESC+"[u"
  351. CLREOL
  352. RETURN
  353.  
  354.  
  355. ;***********************************************************************
  356. '
  357. ' This is a subroutine that displays the new prompt and then sets the color to
  358. ' the default for input.
  359.  
  360. :displayprompt
  361. DISPFILE PPEPATH()+"FLAGNEW",LANG
  362. DEFCOLOR
  363. RETURN
  364.  
  365.  
  366. ;***********************************************************************
  367. '
  368. ' This is a subroutine that checks the filenames() array to locate the next
  369. ' file on screen.  If RIPscrip is used, then special commands (which are
  370. ' passed via a mouse-click from the caller's terminal, are used to identify
  371. ' which file is desired.
  372. '
  373. ' If a valid filename is found, it is stored in a variable called filename.
  374. ' Also, it calls another subroutine to highlight the filename on the screen.
  375.  
  376. :findfile
  377. IF (rip) THEN
  378.   newy = 0
  379.   key = ""
  380.   WHILE (newy = 0) DO
  381.     key = INKEY()      ' watch for the next character
  382.     newy = ASC(key)
  383.     IF (newy >= 129 & newy <= 151) THEN
  384.       newy = newy - 128
  385.       IF (filenames(newy) <> "") THEN
  386.         GOSUB highlight
  387.         filename = filenames(newy)
  388.         RETURN
  389.       ELSE
  390.         newy = 0
  391.       ENDIF
  392.     ENDIF
  393.   ENDWHILE
  394. ELSE
  395.   WHILE (newy < oldy) DO
  396.     newy = newy + 1
  397.     IF (filenames(newy) <> "") THEN
  398.       GOSUB highlight
  399.       filename = filenames(newy)
  400.       RETURN
  401.     ENDIF
  402.   ENDWHILE
  403. ENDIF
  404.  
  405. ' no valid filename was found, return with an empty filename
  406. filename = ""
  407. RETURN
  408.  
  409.  
  410. ;***********************************************************************
  411. '
  412. ' This is a subroutine that highlights the filename moving the cursor to the
  413. ' correct line and then changing the color to black on white and printing the
  414. ' filename.  Prior to highlighting the filename, it saves a color image of the
  415. ' filename so that, when it comes time to unhighlight the file, the image can
  416. ' be restored.
  417.  
  418. :highlight
  419. ' move the cursor back to where it started, at the bottom, and then move
  420. ' it up to the appropriate line on the screen.
  421. PRINT ESC+"[u"+ESC+"["+STRING(oldy-newy)+"A"
  422.  
  423. ' get the file image (text & attributes) for later restoration
  424. fileimage = SCRTEXT(1,newy,13,TRUE)
  425.  
  426. ' then highlight the filename and return
  427. COLOR @X70
  428. PRINT filenames(newy)+CR
  429. RETURN
  430.  
  431.  
  432. ;***********************************************************************
  433. '
  434. ' This is a subroutine that unhighlights the filename by printing the file
  435. ' image, which includes color codes as well as the filename.
  436.  
  437. :unhighlight
  438. PRINT fileimage+CR
  439. RETURN
  440.  
  441.  
  442. ;***********************************************************************
  443. '
  444. ' This subroutine scans the screen at startup to see and fills an array called
  445. ' filenames() with the names of all files found on screen.  If RIPscrip is in
  446. ' use, it will also send out RIPscrip commands to define the location of the
  447. ' filenames on screen so that the caller can use a mouse to point and click.
  448.  
  449. :scanforfiles
  450. IF (GRAFMODE() = "R") THEN
  451.   rip = TRUE
  452. ENDIF
  453.  
  454. ' NOTE:  This loop is unnecessary because PPL automatically initializes
  455. '        all array elements to 0 or blank
  456. '
  457. ' FOR newy=1 TO 23
  458. '   filenames(newy) = ""   ' initialize the array elements
  459. ' NEXT
  460.  
  461. newy = 1
  462. WHILE (newy > 0) DO
  463.   ' get a filename off the screen ... if a filename is found, the filename
  464.   ' variable will be updated, if no more filenames are found, newy will be
  465.   ' set to 0.
  466.   SCRFILE newy, filename
  467.  
  468.   IF (newy <> 0) THEN
  469.     ' store the filename that was found into an array
  470.     filenames(newy) = filename
  471.  
  472.     ' If in RIPscrip mode, define the mouse region where the filename is
  473.     ' located.  The coordinates are defined in X,Y coordinates of 0,newy and
  474.     ' 13,newy+1.  The X coordinate (0 to 13) defines the length of the name.
  475.     ' The Y coordinate (newy to newy+1) defines the height of the name.
  476.     ' An 8x8 font is assumed.  The CHR(newy+128) is a "command" that we will
  477.     ' be using to communicate back to FLAG.PPE the position of the file being
  478.     ' selected via mouse click.
  479.     IF (rip) THEN
  480.       MOUSEREG 0,1,newy,13,newy+1,8,8,TRUE,FALSE," "+CHR(newy+128)
  481.     ENDIF
  482.     INC newy
  483.   ENDIF
  484. ENDWHILE
  485.  
  486. ' finish up the mouse region definitions
  487. IF (rip) THEN
  488.   MPRINT "!|#|#|#"+CR+chr(10)
  489. ENDIF
  490. RETURN
  491.  
  492. ;***********************************************************************
  493.